<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <style>
        table.gridtable {
            font-family: verdana,arial,sans-serif;
            font-size:11px;
            color:#333333;
            border-width: 1px;
            border-color: #666666;
            border-collapse: collapse;
        }
        table.gridtable th {
            border-width: 1px;
            padding: 8px;
            border-style: solid;
            border-color: #666666;
            background-color: #dedede;
        }
        table.gridtable td {
            border-width: 1px;
            padding: 8px;
            border-style: solid;
            border-color: #666666;
            background-color: #ffffff;
        }
        span{
            text-align: right;
        }
    </style>
</head>
<body>
<div id="box_body">
    <table class="gridtable">
        <tr>
        </tr>
        <tr>
            <td>
                <span>用户名：</span>

            </td>
            <td>
                <input type="text" v-model="user.name" />
            </td>
        </tr>
        <tr>
            <td>
                <span>
                    密码：
                </span>

            </td>
            <td>
                <input type="text" v-model="user.pwd" />
            </td>
        </tr>
        <tr>
            <td  style="align-content: center">
                <button type="button" value="登陆" @click="login">登陆</button>
            </td>
            <td  style="align-content: center">
                <button type="button" value="注册" @click="register">注册</button>
            </td>
        </tr>
    </table>
</div>
</body>
<script>
    new Vue({
        el : "#box_body",
        data : {
            user:{}
        },
        methods : {
            login:function(){
                axios({
                    method :"POST",
                    url : "/user/login",
                    data : this.user
                }).then(res=>{
                    if (res.data=="success") {
                        location.href = "/to/toFindAll"
                    }else {
                        alert("登陆失败");
                    }
                })
            },
            register:function() {
                location.href = "/to/toRegister"
            }
        }
    })
</script>
</html>